package com.dailyblue.java.io;

import java.io.*;

// FileInputStream 文件输入流
public class DemoD {

    private static void a() throws FileNotFoundException, IOException {
        File file = new File("D://a//a//a.txt");
        InputStream in = new FileInputStream(file);
        // 读取内容
        int by = in.read();
        System.out.println((char) by);
        in.close();
    }

    private static void b() throws FileNotFoundException, IOException {
        File file = new File("D://a//a//a.txt");
        InputStream in = new FileInputStream(file);
        // 读取内容
        while (true) {
            int by = in.read();
            if (by == -1) {
                break;
            }
            System.out.print((char) by);
        }
        in.close();
    }

    private static void c() throws FileNotFoundException, IOException {
        InputStream in = new FileInputStream("D://a//a//a.txt");
        byte[] bytes = new byte[6];
        while (true) {
            int len = in.read(bytes);
            if (len == -1) {
                break;
            }
            String s = new String(bytes, 0, len);
            System.out.print(s);
        }
        in.close();
    }

    public static void main(String[] args) throws FileNotFoundException, IOException {
        c();
    }
}
